<template>
  <van-field
    v-model="data.num"
    :label="name"
    :placeholder="placeholder"
    type="number"
    :disabled="disabled"
    @input="input"
    required
  />
</template>
<script>
export default {
  props: ['value', 'disabled', 'props', 'required', 'isBusiness', 'title'],
  data: function () {
    return {
      data: {
        num: null,
        displayName: '',
      },
    }
  },
  computed: {
    myprops() {
      return this.props ? this.props : []
    },
    name() {
      let val = this.myprops.find((x) => x.FLPR_Code == 'name')
      if (val) {
        if (this.isBusiness) {
          return val.BFFP_Value ? val.BFFP_Value : '数字'
        } else {
          return val.FFLP_Value ? val.FFLP_Value : '数字'
        }
      }
      return '数字'
    },
    placeholder() {
      let val = this.myprops.find((x) => x.FLPR_Code == 'placeholder')
      if (val) {
        if (this.isBusiness) {
          return val.BFFP_Value ? val.BFFP_Value : '请选择'
        } else {
          return val.FFLP_Value ? val.FFLP_Value : '请选择'
        }
      }
      return '请选择'
    },
  },
  methods: {
    input() {
      this.data.displayName = this.data.num
      this.$emit('input', JSON.stringify(this.data))
      this.$emit('display', this.data.displayName)
    },
  },
  mounted: function () {
    if (this.value) {
      this.data = JSON.parse(this.value)
    }
  },
}
</script>
<style scoped>
.el-form-item {
  margin: 10px !important;
}
</style>